import logging
from api.ihrm_login_api import IhrmLoginApi
from common.assert_tools import commom_assert
import pytest
from common.read_json_tools import read_json_data
from config import BASE_PATH


# 定义测试类  --  测试用例层
class TestIhrmLoginParams:
    def setup_class(self):
        # 创建实例
        self.ihrm = IhrmLoginApi()

    filename = BASE_PATH+"/data/ihrm_login.json"
    login_data = read_json_data(filename)

    # 定义 通用 测试方法
    @pytest.mark.parametrize("desc, req_body, ststus_code, success, code, message", login_data)
    def test_Login(self, desc, req_body, ststus_code, success, code, message):
        # 调用自己封装的api，获取响应结果
        resp = self.ihrm.Login(req_body)
        # print(desc, ":", resp.json())
        # 使用日志替换 print
        logging.info(f"这是晚自习作业题的日志信息:{resp.json()}")

        # 断言
        commom_assert(resp, ststus_code, success, code, message)
